package huawei.year2017;

import java.util.Scanner;

/**
 * Created by Hyman on 2017/3/17.
 *
 * 集五福
 * 输入若干个“11010”、“00110”的由0,1组成的长度为5的字符串，代表团队中每个人副卡获得情况
 * 1表示已经获得该福卡，每个人福卡不重复
 * 输出该团队能凑齐多少套五福
 */
public class CollectWufu {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        String[] strArray = new String[10];
        int num = 0;

        while(input.hasNext()) {
            String line = input.next();
            if(!line.isEmpty()) {
                strArray[num]= line;
                num++ ;
            }
        }

        int one=0, two=0, three=0, four=0, five=0 ;

        for(int i=0;i<num;i++){
            one += strArray[i].charAt(0)-48;
            two += strArray[i].charAt(1)-48;
            three += strArray[i].charAt(2)-48;
            four += strArray[i].charAt(3)-48;
            five += strArray[i].charAt(4)-48;
        }

        int result = 0;
        result = Math.min(Math.min(Math.min(Math.min(one, two), three), four), five);
        System.out.println(result);
    }
}
